import time
from selenium import webdriver
from selenium.webdriver.common.by import By

class QqEmile:
    def __init__(self):
        # 打开浏览器
        self.driver = webdriver.Chrome()
        self.driver.maximize_window()
        # 打开qq邮箱
        self.driver.get('https://mail.qq.com/')
        self.userinfo = {'username': '123456','password': '123456'}


    def register(self):
        # 切换frame页面
        self.driver.switch_to.frame('login_frame')
        time.sleep(2)
        # 输入用户名
        time.sleep(2)
        #self.driver.find_element(By.ID, 'u').send_keys('123456')
        self.driver.find_element(By.ID, 'u').send_keys(self.userinfo['username'])
        # 输入密码
        time.sleep(2)
        # self.driver.find_element(By.ID, 'p').send_keys('123456')
        self.driver.find_element(By.ID, 'p').send_keys(self.userinfo['password'])
        # 点击登录
        time.sleep(2)
        self.driver.find_element(By.ID, 'login_button').click()

    def quit(self):
        time.sleep(2)
        self.driver.quit()

if __name__ == '__main__':
    qq = QqEmile()
    qq.register()
    qq.quit()